package com.zide.video.controller;

import java.util.List;

import com.zide.common.core.vo.CommonParamIdVO;
import com.zide.video.domain.vo.result.VideoResultVO;
import com.zide.video.domain.vo.save.VideoSaveVO;
import com.zide.video.domain.vo.search.VideoSearchVO;
import com.zide.video.service.IVideoService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zide.common.core.domain.PageResult;
import com.zide.common.core.domain.CommonResult;
import static com.zide.common.core.domain.CommonResult.getResult;
import static com.zide.common.core.domain.CommonResult.success;

/**
 * 视频信息Controller
 * 
 * @author zide
 * @date 2024-05-08
 */
@Tag(name = "视频信息")
@RestController
@RequestMapping("/video")
public class VideoController {
    @Resource
    private IVideoService videoService;


    @Operation(summary = "查询视频信息列表")
    @GetMapping("/list")
    public CommonResult list(VideoSearchVO searchVO) {

        PageResult<VideoResultVO> list = videoService.searchVideoPageList(searchVO);
        return success(list);
    }

    @Operation(summary = "查询热门视频")
    @GetMapping("/hot")
    public CommonResult searchHotList() {
        List<VideoResultVO> list = videoService.searchHotList();
        return success(list);
    }

    @Operation(summary = "获取视频信息详细信息")
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id) {
        return success(videoService.selectVideoById(id));
    }

    @Operation(summary = "新增视频信息")
    @PostMapping
    public CommonResult add(@RequestBody VideoSaveVO saveVO) {
        return getResult(videoService.saveVideo(saveVO));
    }

    @Operation(summary = "修改视频信息")
    @PutMapping
    public CommonResult edit(@RequestBody VideoSaveVO saveVO){
        return getResult(videoService.updateVideo(saveVO));
    }

    @Operation(summary = "删除视频信息")
	@DeleteMapping
    public CommonResult remove(@RequestBody CommonParamIdVO idVO){
        return getResult(videoService.removeVideoByIds(idVO));
    }
}
